package org.example.kdxf.demos.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.example.kdxf.demos.entity.User;
import org.example.kdxf.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
@Api(tags = "用户管理接口")  // 控制器描述
public class UserController {

    @ApiOperation(value = "获取用户详情", notes = "根据用户ID获取用户详细信息")
    @GetMapping("/{id}")
    public ResponseEntity<User> getUser(
            @ApiParam(name = "id", value = "用户ID", required = true, example = "123")
            @PathVariable Long id) {
        // 实现逻辑
        return null;
    }
    @ApiOperation(value = "获取用户", notes = "根据用户ID获取用户详细信息1111")
    @GetMapping("/test1")
    public String test(Integer num){
        if(num==1){
            return "你好";
        }
        if(num==2){
            return "hello";
        }
        return "艾明依";
    }
    @ApiOperation(value = "22", notes = "根据用户ID获取用户详细信息2222")
    @PostMapping("test2")
    public String testTwo(@RequestBody User user){
        if(user != null){
            if(user.getId().equals(1L)){
                return "艾明依";
            }
            if(user.getId().equals(2L)){
                return "任媛媛";
            }
        }
        return "LW";

    }
    @Autowired
    private UserService userServiceImpl;

    @GetMapping("/test3")
    public User testThree(Integer num){
        User  user=userServiceImpl.testThree(num);
        return user;
    }

}